#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;

#define in read()
#define pii pair<int,int>
#define fi first
#define se second
#define FILE(x) freopen(x".in","r",stdin);\
	freopen(x".out","w",stdout);
#define pb push_back

int read(){
	int x = 0,sgn = 1;char ch = getchar();
	for(;!isdigit(ch);ch = getchar()) if(ch == '-') sgn = -1;
	for(;isdigit(ch);ch = getchar()) x = (x<<1)+(x<<3)+(ch^48);
	return x*sgn;
}

const int N = 500;
const int inf = 0x3f3f3f3f;

int dep[N<<1],now[N<<1],h[N<<1],maxflow,ans,f[N],x[N],n,cnt = 1,s,t;
struct edge{int v,w,nxt;}e[N<<3];

void link(int x,int y,int w){e[++cnt] = (edge){y,w,h[x]};h[x] = cnt;e[++cnt] = (edge){x,0,h[y]};h[y] = cnt;}

int id(int x,int y){return x + y * n;}

bool bfs(){
	queue<int> q; memset(dep,0,sizeof(dep));
	dep[s] = 1; now[s] = h[s]; q.push(s);
	while(q.size()){
		int x = q.front();q.pop();
		for(int i = h[x],y;i;i = e[i].nxt){
			if(!dep[y = e[i].v] && e[i].w){
				dep[y] = dep[x] + 1; now[y] = h[y];
				q.push(y); if(y == t) return 1;
			}
		}
	}return 0;
}

int dinic(int x,int flow){
	if(x == t) return flow; int res = flow;
	for(int i = now[x],y;i && res;i = e[i].nxt){
		now[x] = i;
		if(dep[y = e[i].v] == dep[x] + 1 && e[i].w){
			int tt = dinic(y,min(e[i].w,res));
			if(!tt) dep[y] = 0;
			e[i].w -= tt; e[i^1].w += tt; res -= tt;
		}
	}return flow - res;
}

int main (){
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
	n = in;
	for(int i = 1;i <= n;i++) x[i] = in;
	for(int i = 1;i <= n;i++)
		for(int j = 0;j < i;j++){
			if(x[j] <= x[i]) f[i] = max(f[i],f[j]+1);
		}
	for(int i = 1;i <= n;i++) ans = max(ans,f[i]);
	printf("%d\n",ans);
	s = 0;t = 2*n+1;
	for(int i = 1;i <= n;i++){
		if(f[i] == 1) link(s,id(i,0),1);
		if(f[i] == ans) link(id(i,1),t,1);
		link(id(i,0),id(i,1),1);
		for(int j = i+1;j <= n;j++)
			if(x[i] <= x[j] && f[j] == f[i]+1) link(id(i,1),id(j,0),1);
	}
	int flow;
	while(bfs()) while(flow = dinic(s,inf)) maxflow += flow;
	printf("%d\n",maxflow);
	if(n > 1) link(id(1,0),id(1,1),inf); link(s,id(1,0),inf);
	if(f[n] == ans) link(id(n,1),t,inf); if(n > 1) link(id(n,0),id(n,1),inf);
	while(bfs()) while(flow = dinic(s,inf)) maxflow += flow;
	printf("%d\n",maxflow);
	return 0;
}
